package com.qdxwx.data.service.teacher;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.data.mapper.teacher.TeacherApplyMapper;
import com.qdxwx.models.teacher.TeacherApply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 接口
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class TeacherApplyServiceImpl implements TeacherApplyService {

    @Autowired
    private TeacherApplyMapper teacherApplyMapper;

    @Override
    public int insert(TeacherApply teacherApply) {
        teacherApply.setCreateTime(LocalDateTime.now());
        return teacherApplyMapper.insertTeacherApply(teacherApply);
    }

    @Override
    public int delete(int id) {
        if(id < 1) return 0;
        return teacherApplyMapper.deleteById(id);
    }

    @Override
    public int update(TeacherApply teacherApply) {
        if(teacherApply.getId() < 1) return 0;
        teacherApply.setUpdateTime(LocalDateTime.now());
        return teacherApplyMapper.updateTeacherApply(teacherApply);
    }

    @Override
    public TeacherApply get(int tcId) {
        return teacherApplyMapper.selectById(tcId);
    }

    @Override
    public List<TeacherApply> getList(TeacherApply teacherApply, PageRequest page) {
        return teacherApplyMapper.selectList(teacherApply,page);
    }

    @Override
    public long count(TeacherApply teacherApply) {
        return teacherApplyMapper.selectCount(teacherApply);
    }
}
